package cn.opopopo.wordexport.util;

import org.apache.poi.xwpf.usermodel.XWPFDocument;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

public class DocumentToByteArray {
    public static byte[] convertXWPFDocumentToByteArray(XWPFDocument document) {
        byte[] byteArray = null;

        try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
            document.write(bos);
            byteArray = bos.toByteArray();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return byteArray;
    }
}